<?php
/**
 * @description : auto redirect to reback url.
 * @author      : stephen.mo
 * @date        : 2010/09/10
 */
require_once "TVB/OAuth/common.inc.php";
$reback_url = (isset($_REQUEST['oauth_reback'])) ? $_REQUEST['oauth_reback'] : NULL;
$lang       = (isset($_REQUEST['lang'])) ? $_REQUEST['lang'] : OAuthUtils::getLang();

//not allow null url.
if (empty($reback_url)) {
    $reback_url = OAuthUtils::genericError(array(1030));
}

//check url if need to match regular.
if (OAuthModelConfig::NEED_MATCH_REGULAR) {
    if (!in_array(OAuthUtils::getDomainByUrl($reback_url),OAuthModelConfig::$default_allow_domain)) {
        $reback_url = OAuthUtils::genericError(array(1030));
    }
}

//redirect.
header("Location:$reback_url");
exit;
?>
